library(survey)
library(foreign)
library(ggplot2)
library(ggrepel)
library(cowplot)
library(dplyr)
library(stargazer)
library(performance)

## see PCM_cleaning.R for data cleaning
#load("~/Dropbox/Public_Conf_Mil/Data_and_code/wave2_data/clean_dataw2.RData")
# This is saved: C:\Users\Robert Allred\Documents\Duke\Civ_Mil_Appendix\Code

## Create weighted survey design object
w2_design <-
  svydesign(
    id = ~ 1,
    weights = ~ weight2,
    data = df
  )

## creating figure 2-9 with the multivariate model
# model: multivariate model based on demographics, logit specification, DV: Q11 dummy variable

demo_mod <- svyglm(Q11_d ~ dem + rep + ideo3 + male + white + black + hispanic + asian + income5 +
                     EDUC5 + unemployed + silent + boomer + genx + millen + activeduty + vet +
                     social + family + midwest + south + west + catholic + christian + norelig +
                     city + rural + married + A2 + A3 + A4 + A5 + A6 + A7 + A8,
                   family = binomial(link = "logit"),
                   design = w2_design)

stargazer(demo_mod)
stargazer(demo_mod, single.row = TRUE)
check_collinearity(demo_mod)

